Skip to content

Add MPC profiling metrics#421

Open
zhouwfang wants to merge 4 commits intomainfrom
zhoufang/iop-315-profile
Open

Add MPC profiling metrics#421
zhouwfang wants to merge 4 commits intomainfrom
zhoufang/iop-315-profile

Conversation

@zhouwfang
Copy link
Copy Markdown
Contributor

No description provided.

@zhouwfang zhouwfang requested review from benr-ml and jonas-lj April 8, 2026 22:29
@zhouwfang zhouwfang requested a review from bmwill as a code owner April 8, 2026 22:29
@zhouwfang zhouwfang force-pushed the zhoufang/iop-315-profile branch from efd6d1b to f8c6e94 Compare April 8, 2026 22:35
Comment thread crates/hashi/src/grpc/client.rs Outdated
Comment on lines +131 to +134
let response_size = response.get_ref().encoded_len();
let resp = RetrieveMessagesResponse::try_from(response.get_ref())
.map_err(|e| tonic::Status::internal(e.to_string()))?;
Ok((resp, request_size, response_size))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to add metrics to the clients/servers then we should leverage middleware as it will be much cleaner and keep the business logic free from this instrumentation.

You can take a look at MystenLabs/sui-rust-sdk#237 for how middleware can be added to grpc clients and https://github.com/bmwill/sui/blob/bf4f4c2e66964ba3668baa2accbf0521c9aa0e81/crates/sui-rpc-api/src/lib.rs#L229-L243 for how middleware can be added to the server side (I think we do already do some server side metrics using this paradigm.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted the client.rs changes. Byte counting now lives in RpcP2PChannel which is the metrics wrapper around the client, so grpc::Client stays clean.

I looked at both references. The challenge with applying CallbackLayer on the client side for our use case: Client instances are cached in CommitteeSet and shared across protocols. The middleware wouldn't know which protocol is active, so we'd lose protocol labels on the bytes metrics. We need per-protocol labels to compare communication cost across protocols.

RpcP2PChannel is created per-protocol with the label, so it's the natural place for this.

Comment thread crates/hashi/src/mpc/mpc_except_signing.rs Outdated
@zhouwfang zhouwfang force-pushed the zhoufang/iop-315-profile branch from 6d76148 to da96dd7 Compare April 15, 2026 22:57
@zhouwfang zhouwfang force-pushed the zhoufang/iop-315-profile branch from 81b0bc2 to 3b7fc5c Compare April 15, 2026 23:07
@zhouwfang zhouwfang requested a review from bmwill April 15, 2026 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants